package cn.qayy.po;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

import cn.qayy.dto.PolicyDTO;
import cn.qayy.utils.ArithUtil;
import cn.qayy.utils.DateUtils;
import cn.qayy.utils.StringUtil;
/**
 * 协议表 实体 
 */
@SuppressWarnings("all")
public class Policy implements Serializable{
	//批量导入的模板字段：#############################################
	private String province="";//省份
	private String city="";//地市
	private String qudaolie="";//条线
	private String terminaltype="";//渠道
	private String product="";//品种
	private String page="";//包装
	private String client="";//客户
	private String daibiao="";//代表
	private String mgr="";//经理
	private String qsterminal="";//入货乙方
	private String terminal="";//协议备注
	private String mode="";//模式
	private String zijingchengben="";//资金成本
	private String jsmode="";//结算方式
	private String kaipiaojia="";//开票价
	private String tuiguangmoney="";//1服务费（基础）
	private String fapiaomoney="";//3服务费（财务）
	private String daibiaomoney="";//4服务费（开发）
	private String kaifajianlishixiang="";//5开发奖励
	private String kaifaMgr="0";//业务员开发奖励
	private String xieyibiaogang="";//协议标杆
	private String kaifashixiang="";//开发时限
	private String xieyistarttime="";//开始时间
	private String xieyiendtime="";//结束时间
	private String guihuanriqi="";//协议状态
	private String kaipiaofangshi="";//票据方案
	private String shoukuangren="";//收款人
	private String kaihuhang="";//开户行
	private String zhanghao="";//账号
	//修订标识 N E
	private Integer id;
	//批量导入的模板：##############################################
	
	//标准测算价、中标价，额外通过表录入
	private String biaozhuncsdj="0";//标准测算价
	private String zhongbiaojia="0";//中标价
	/*** 系统计算字段**/
	private String dijia="0";//协议测算价
	private String today=DateUtils.dateToString(new Date(),"yyyy/MM/dd HH:mm:ss");//协议录入日期
	private String zhongdiantubie="";//录入员
	private String basicpolicy="0";//基础政策

	private Date mtime=new Date();//更新时间
	/***
	 * 拟定废弃的,不用删除，用于参考#########################################################
	 */
	//	private String year;//年份
	//	private String terminallve="";//级别
	//	private String fenbu="";//分布
	//	private String zhengheqs="";//QS名
	//	private String daqu="";//大区
	//	private String space="";//片区
	//	private String county="";//区县
	//	private String terminalQs="";//协议Qs名，匹配协议
	//	private String kaifazhibaoshijian="";//开发指标时间
	//	private String kaifabaozhengjing="";//开发保证金
	//	private String shichangbaozhengjing="";//市场保证金
	//	private String cunxiaozongzhibiao="";//纯销总指标
	//	private String shoufukuang="";//首付款
	//	private String kaifazhibiao="";//开发指标
	//	private String zhushi="";//注释
	//	private String kaifajianlimemo="";// 开发奖励备注
	//	private String terminalLowLine="";//最低起付线，
	//	private String bannianzongzhibiao="";//半年总指标			
	//	private String wancheng="";//纯销总指标完成情况
	//	private String bannianwancheng="";//半年总指标完成情况
	//	private String caiwubutie="";//财务补贴
	//	private String jicengbutie="";//基层补贴
	//	private String cuxiaocesuanjia="";//促销测算价
	//	private String cuxiaofeiyong="";//促销费用
	//	private String tiaozhengtuiguang="";//调整推广
	//	private String yinyukaiguang="";//盈余开关
	//	private String danweiticheng="";//单位提成	
	//	private String danweijianli="";//单位奖励,临时保存了开发奖励月数
	/***
	 * 拟定废弃的#########################################################
	 */

	/***
     * 通过DTO初始化
     * @param dto
     * @return
     */
    public Policy setByDTO(PolicyDTO dto) {
    	this.province = dto.getProvince();
		this.city = dto.getCity();
		this.qudaolie = dto.getQudaolie();
		this.terminaltype = dto.getTerminaltype();
		this.product = dto.getProduct();
		this.page = dto.getPage();
		this.client = dto.getClient();
		this.daibiao = dto.getDaibiao();
		this.mgr = dto.getMgr();
		this.qsterminal = dto.getQsterminal();
		this.terminal = dto.getTerminal();
		this.mode = dto.getMode();
		//资金成本，如用户没有填写是由系统去初始化，故这里不能调用保留2位小数的方法，应原样初始化
		if (!StringUtil.isNotBlank(dto.getZijingchengben())) {
			this.zijingchengben = dto.getZijingchengben();
		} else {
			//用户已经填写了资金成本
			this.zijingchengben =  ArithUtil.format2bit(dto.getZijingchengben());
		}
		this.jsmode = dto.getJsmode();
		this.kaipiaojia = ArithUtil.format2bit(dto.getKaipiaojia());
		this.tuiguangmoney = ArithUtil.format2bit(dto.getTuiguangmoney());
		this.fapiaomoney = ArithUtil.format2bit(dto.getFapiaomoney());
		this.daibiaomoney = ArithUtil.format2bit(dto.getDaibiaomoney());
		
		this.kaifajianlishixiang = ArithUtil.format2bit(dto.getKaifajianlishixiang());
		float kafai = StringUtil.parseFloat(this.kaifajianlishixiang);
		//Y/Z产品不给业务员开发奖励
		if(this.product.contains("Y")||this.product.contains("Z")) {
			this.kaifaMgr = "0";
		}
		//具有客户开发奖励时，业务经理才有奖励提成
		if(kafai > 0) {
			if(this.product.contains("A")) {
				if(this.page.contains("12")) {
					this.kaifaMgr = "0.2";
				}
				if(this.page.contains("24")) {
					this.kaifaMgr = "0.4";
				}
				if(this.page.contains("36")) {
					this.kaifaMgr = "0.6";
				}
				if(this.page.contains("48")) {
					this.kaifaMgr = "0.8";
				}
				if(this.page.contains("20")) {
					this.kaifaMgr = "0.33";
				}
				if(this.page.contains("30")) {
					this.kaifaMgr = "0.5";
				}
				if(this.page.contains("40")) {
					this.kaifaMgr = "0.67";
				}
				if(this.page.contains("60")) {
					this.kaifaMgr = "1";
				}
			}
		} else {
			this.kaifaMgr = "0";
		}
		//用户录入的业务经理开发奖励
		float kaifaMgr = StringUtil.parseFloat(dto.getKaifaMgr())==null?0:StringUtil.parseFloat(dto.getKaifaMgr());
		if(kaifaMgr > 0) {//如果用户录入了，说明该终端也是有业务经理的内部奖励的
			if(this.product.contains("A")) {
				if(this.page.contains("12")) {
					this.kaifaMgr = "0.2";
				}
				if(this.page.contains("24")) {
					this.kaifaMgr = "0.4";
				}
				if(this.page.contains("36")) {
					this.kaifaMgr = "0.6";
				}
				if(this.page.contains("48")) {
					this.kaifaMgr = "0.8";
				}
				if(this.page.contains("20")) {
					this.kaifaMgr = "0.33";
				}
				if(this.page.contains("30")) {
					this.kaifaMgr = "0.5";
				}
				if(this.page.contains("40")) {
					this.kaifaMgr = "0.67";
				}
				if(this.page.contains("60")) {
					this.kaifaMgr = "1";
				}
			}
		}
				
		this.xieyibiaogang = dto.getXieyibiaogang();
		this.kaifashixiang = dto.getKaifashixiang();
		this.xieyistarttime = DateUtils.parseDate(dto.getXieyistarttime());
		this.xieyiendtime = DateUtils.parseDate(dto.getXieyiendtime());
		this.guihuanriqi = dto.getGuihuanriqi();
		this.kaipiaofangshi = dto.getKaipiaofangshi();
		this.shoukuangren = dto.getShoukuangren();
		this.kaihuhang = dto.getKaihuhang();
		this.zhanghao = dto.getZhanghao();
    	return this;
    }

	public Policy(String province, String city, String qudaolie, String terminaltype, String product, String page,
			String client, String daibiao, String mgr, String qsterminal, String terminal, String mode,
			String zijingchengben, String jsmode, String kaipiaojia, String tuiguangmoney, String fapiaomoney,
			String daibiaomoney, String kaifajianlishixiang, String kaifaMgr, String xieyibiaogang,
			String kaifashixiang, String xieyistarttime, String xieyiendtime, String guihuanriqi, String kaipiaofangshi,
			String shoukuangren, String kaihuhang, String zhanghao, Integer id, String biaozhuncsdj,
			String zhongbiaojia, String dijia, String today, String zhongdiantubie, String basicpolicy, Date mtime) {
		super();
		this.province = province;
		this.city = city;
		this.qudaolie = qudaolie;
		this.terminaltype = terminaltype;
		this.product = product;
		this.page = page;
		this.client = client;
		this.daibiao = daibiao;
		this.mgr = mgr;
		this.qsterminal = qsterminal;
		this.terminal = terminal;
		this.mode = mode;
		this.zijingchengben = zijingchengben;
		this.jsmode = jsmode;
		this.kaipiaojia = kaipiaojia;
		this.tuiguangmoney = tuiguangmoney;
		this.fapiaomoney = fapiaomoney;
		this.daibiaomoney = daibiaomoney;
		this.kaifajianlishixiang = kaifajianlishixiang;
		this.kaifaMgr = kaifaMgr;
		this.xieyibiaogang = xieyibiaogang;
		this.kaifashixiang = kaifashixiang;
		this.xieyistarttime = xieyistarttime;
		this.xieyiendtime = xieyiendtime;
		this.guihuanriqi = guihuanriqi;
		this.kaipiaofangshi = kaipiaofangshi;
		this.shoukuangren = shoukuangren;
		this.kaihuhang = kaihuhang;
		this.zhanghao = zhanghao;
		this.id = id;
		this.biaozhuncsdj = biaozhuncsdj;
		this.zhongbiaojia = zhongbiaojia;
		this.dijia = dijia;
		this.today = today;
		this.zhongdiantubie = zhongdiantubie;
		this.basicpolicy = basicpolicy;
		this.mtime = mtime;
	}

	public String getZhongdiantubie() {
		return zhongdiantubie;
	}
	public void setZhongdiantubie(String zhongdiantubie) {
		this.zhongdiantubie = zhongdiantubie;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getShoukuangren() {
		return shoukuangren;
	}
	public void setShoukuangren(String shoukuangren) {
		this.shoukuangren = shoukuangren;
	}
	public String getKaihuhang() {
		return kaihuhang;
	}
	public void setKaihuhang(String kaihuhang) {
		this.kaihuhang = kaihuhang;
	}
	public String getZhanghao() {
		return zhanghao;
	}
	public void setZhanghao(String zhanghao) {
		this.zhanghao = zhanghao;
	}
	public String getDaibiao() {
		return daibiao;
	}
	public void setDaibiao(String daibiao) {
		this.daibiao = daibiao;
	}
	public String getBiaozhuncsdj() {
		return biaozhuncsdj;
	}
	public void setBiaozhuncsdj(String biaozhuncsdj) {
		this.biaozhuncsdj = biaozhuncsdj;
	}
	public String getToday() {
		return today;
	}
	public void setToday(String today) {
		this.today = today;
	}
	public String getKaifajianlishixiang() {
		return kaifajianlishixiang;
	}
	public void setKaifajianlishixiang(String kaifajianlishixiang) {
		this.kaifajianlishixiang = kaifajianlishixiang;
	}
	public String getZijingchengben() {
		return zijingchengben;
	}
	public void setZijingchengben(String zijingchengben) {
		this.zijingchengben = zijingchengben;
	}
	public String getGuihuanriqi() {
		return guihuanriqi;
	}
	public void setGuihuanriqi(String guihuanriqi) {
		this.guihuanriqi = guihuanriqi;
	}
	public String getQsterminal() {
		return qsterminal;
	}
	public void setQsterminal(String qsterminal) {
		this.qsterminal = qsterminal;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getMgr() {
		return mgr;
	}
	public void setMgr(String mgr) {
		this.mgr = mgr;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getProduct() {
		return product;
	}
	public void setProduct(String product) {
		this.product = product;
	}
	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public String getClient() {
		return client;
	}
	public void setClient(String client) {
		this.client = client;
	}
	public String getTerminal() {
		return terminal;
	}
	public void setTerminal(String terminal) {
		this.terminal = terminal;
	}
	public String getTerminaltype() {
		return terminaltype;
	}
	public void setTerminaltype(String terminaltype) {
		this.terminaltype = terminaltype;
	}
	public String getMode() {
		return mode;
	}
	public void setMode(String mode) {
		this.mode = mode;
	}
	public String getJsmode() {
		return jsmode;
	}
	public void setJsmode(String jsmode) {
		this.jsmode = jsmode;
	}
	public String getTuiguangmoney() {
		return tuiguangmoney;
	}
	public void setTuiguangmoney(String tuiguangmoney) {
		this.tuiguangmoney = tuiguangmoney;
	}
	public String getFapiaomoney() {
		return fapiaomoney;
	}
	public void setFapiaomoney(String fapiaomoney) {
		this.fapiaomoney = fapiaomoney;
	}
	public String getBasicpolicy() {
		return basicpolicy;
	}
	public void setBasicpolicy(String basicpolicy) {
		this.basicpolicy = basicpolicy;
	}
	public String getKaipiaojia() {
		return kaipiaojia;
	}
	public void setKaipiaojia(String kaipiaojia) {
		this.kaipiaojia = kaipiaojia;
	}
	public String getZhongbiaojia() {
		return zhongbiaojia;
	}
	public void setZhongbiaojia(String zhongbiaojia) {
		this.zhongbiaojia = zhongbiaojia;
	}
	public String getDaibiaomoney() {
		return daibiaomoney;
	}
	public void setDaibiaomoney(String daibiaomoney) {
		this.daibiaomoney = daibiaomoney;
	}
	public String getXieyibiaogang() {
		return xieyibiaogang;
	}
	public void setXieyibiaogang(String xieyibiaogang) {
		this.xieyibiaogang = xieyibiaogang;
	}
	public String getKaifashixiang() {
		return kaifashixiang;
	}
	public void setKaifashixiang(String kaifashixiang) {
		this.kaifashixiang = kaifashixiang;
	}
	public String getDijia() {
		return dijia;
	}
	public void setDijia(String dijia) {
		this.dijia = dijia;
	}
	public String getXieyistarttime() {
		return xieyistarttime;
	}
	public void setXieyistarttime(String xieyistarttime) {
		this.xieyistarttime = xieyistarttime;
	}
	public String getXieyiendtime() {
		return xieyiendtime;
	}
	public void setXieyiendtime(String xieyiendtime) {
		this.xieyiendtime = xieyiendtime;
	}
	public String getKaipiaofangshi() {
		return kaipiaofangshi;
	}
	public void setKaipiaofangshi(String kaipiaofangshi) {
		this.kaipiaofangshi = kaipiaofangshi;
	}
	public String getQudaolie() {
		return qudaolie;
	}
	public void setQudaolie(String qudaolie) {
		this.qudaolie = qudaolie;
	}
	
	public Date getMtime() {
		return mtime;
	}

	public void setMtime(Date mtime) {
		this.mtime = mtime;
	}

	public Policy() {
	}

	public String getKaifaMgr() {
		return kaifaMgr;
	}

	public void setKaifaMgr(String kaifaMgr) {
		this.kaifaMgr = kaifaMgr;
	}

	@Override
	public String toString() {
		return "Policy [province=" + province + ", city=" + city + ", qudaolie=" + qudaolie + ", terminaltype="
				+ terminaltype + ", product=" + product + ", page=" + page + ", client=" + client + ", daibiao="
				+ daibiao + ", mgr=" + mgr + ", qsterminal=" + qsterminal + ", terminal=" + terminal + ", mode=" + mode
				+ ", zijingchengben=" + zijingchengben + ", jsmode=" + jsmode + ", kaipiaojia=" + kaipiaojia
				+ ", tuiguangmoney=" + tuiguangmoney + ", fapiaomoney=" + fapiaomoney + ", daibiaomoney=" + daibiaomoney
				+ ", kaifajianlishixiang=" + kaifajianlishixiang + ", kaifaMgr=" + kaifaMgr + ", xieyibiaogang="
				+ xieyibiaogang + ", kaifashixiang=" + kaifashixiang + ", xieyistarttime=" + xieyistarttime
				+ ", xieyiendtime=" + xieyiendtime + ", guihuanriqi=" + guihuanriqi + ", kaipiaofangshi="
				+ kaipiaofangshi + ", shoukuangren=" + shoukuangren + ", kaihuhang=" + kaihuhang + ", zhanghao="
				+ zhanghao + ", id=" + id + ", biaozhuncsdj=" + biaozhuncsdj + ", zhongbiaojia=" + zhongbiaojia
				+ ", dijia=" + dijia + ", today=" + today + ", zhongdiantubie=" + zhongdiantubie + ", basicpolicy="
				+ basicpolicy + ", mtime=" + mtime + "]";
	}

	
	
	
}